/*
Web: http://www.jsForms.com
Copyright (C) 2008  Igor Demyanov (mailto:Igor.Demyanov@gmail.com)
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
jsForms.Components.InputFilesComponent={
	Init:function()
	{
		return jsForms.Components.Component.Init.call(this);
	},
	ScanCSS:function(text)
	{
		cssController.ParseCSSText(text);
	},
	ScanJS:function(text)
	{
		try {
			eval(text);
			this.C.ScanLog.text('Scan - OK');
		}catch(e)
		{
			if (e && e.message) {
				this.C.ScanLog.text(e.message);
			}else
			{
				this.C.ScanLog.text('Scan - Error');
			}
		}
	},
	bScanCSS_Click:function()
	{
		this.ScanCSS(this.C.cssText.val());
	},
	bScanJS_Click:function()
	{
		this.ScanJS(this.C.jsText.val());
	},
	FileJS_onLoad: function(e){
		this.ScanJS(e.text);
		alert('Load completed');
	},
	FileCSS_onLoad: function(e){
		this.ScanCSS(e.text);
		alert('Load completed');
	}
};
jsForms.Components.OutputFilesComponent={
	GenerateOutput:function(node,EditComponentType)
	{
		this.C.outputCSS.val(cssController.GenerateCSSFile());
		this.C.outputTemplate[0].innerHTML = '';
		if (!node) {
				return;
		}
		var templateFile = ['jsForms.Templates.'];
		templateFile.push(EditComponentType);
		templateFile.push("='");
		var templateNew =jsForms.DesignMode.CreateTemplate(node);
		templateNew = templateNew.replace(/'/g,'\\\'').replace(/"/g,'\\"');
		templateFile.push(templateNew);
		templateFile.push("';");
		this.C.outputTemplate.val(templateFile.join(''));
	}
};
